package com.ssy.lingxi.order.model.constant;

import java.util.Arrays;

/**
 * 订单支付回调通知中的支付状态枚举
 * @author 万宁
 * @version 2.0.0
 * @date 2021-12-24
 */
public enum OrderPaymentCallbackStatusEnum {
    /**
     * 支付中 - 0
     */
    PAYING(0, "支付中"),

    /**
     * 支付成功 - 1
     */
    SUCCESS(1, "支付成功"),

    /**
     * 支付失败 - 2
     */
    FAILED(2, "支付失败");

    OrderPaymentCallbackStatusEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    private Integer code;
    private String name;

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static OrderPaymentCallbackStatusEnum parse(Integer code) {
        return code == null ? null : Arrays.stream(OrderPaymentCallbackStatusEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
    }
}
